//index.js
//获取应用实例
const app = getApp();
var that;

Page({
  data: {
    inputVal:"",
    inputShowed:false,
    playBookList:[],
    flag:true,
  },



  onLoad: function () {
    console.log("[Console log]:onLoad...")
    that = this;    
  },
 
  onShow: function () {
    console.log("[Console log]:onShow...")
    that.setData({
      flag: true
    })
    wx.request({
      url: app.globalData.URL + '/playArrangement/findPlayArrangement',
      data: {

      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      complete: function (res) {
        console.log(res.data);
        that.setData({
          playBookList: res.data,
          inputVal: "",
        })
        console.log("playBookList:" + that.data.playBookList);
      }
    })


  },
  
  inputTyping: function (e) {
    that = this;
    var value = e.detail.value
    that.setData({
      inputVal: value
    })
    console.log(value)
  },

  showInput: function () {
    that = this;
    that.setData({
      inputShowed: true
    })
  },

  clearInput: function () {
    that = this;
    that.setData({
      // inputShowed: true,
      inputVal: ""
    })
  },

  toTeam: function (e) {
    console.log(e.currentTarget.id);
    wx.navigateTo({
      url: '../user/toTeam/toTeam?id=' + e.currentTarget.id,
    })
  },
  searchData: function () {
    console.log(that.data.inputVal)
    that = this;
    wx.request({
      url: app.globalData.URL + '/playArrangement/searchPlayArrangement',
      data: {
        keyword :that.data.inputVal
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      complete: function (res) {
        console.log(res.data);
        that.setData({
          playBookList: res.data
        })
        if (that.data.playBookList.length == 0){
          that.setData({
            flag: false
          })
        }else{
          that.setData({
            flag: true
          })
        }
        console.log("playBookList:" + that.data.playBookList);
      }
    })
  },
})
